package com.gitee.devinx3.mrg.controller;

import com.gitee.devinx3.mrg.message.MessageHandler;
import com.gitee.devinx3.mrg.message.MsgCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/organizations/{organizationId}/msg")
public class MessageController {

    @Autowired
    private MessageHandler messageHandler;

    @GetMapping
    public void get(@PathVariable("organizationId") String organizationId) {
        messageHandler.publish(new MsgCommand("GET", organizationId, "MessageController.get"));
    }


    @PostMapping
    public void post(@PathVariable("organizationId") String organizationId) {
        messageHandler.publish(new MsgCommand("POST", organizationId, "MessageController.post"));
    }

    @PutMapping
    public void put(@PathVariable("organizationId") String organizationId) {
        messageHandler.publish(new MsgCommand("PUT", organizationId, "MessageController.put"));
    }

    @DeleteMapping
    public void delete(@PathVariable("organizationId") String organizationId) {
        messageHandler.publish(new MsgCommand("DELETE", organizationId, "MessageController.delete"));
    }

}
